package com.gopay.common.order.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseReadDAOImpl;
import com.gopay.common.domain.cps.CpsBatchTaskTargetRel;
import com.gopay.common.order.dao.CpsBatchTaskTargetRelQueryDAO;

/**
 * 批量任务Dao实现类(common-order)
 *
 * @CpsBatchTaskTargetRelDAOImpl.java
 * @author liuxin
 * @2013-3-5 上午11:50:07 www.gopay.com.cn Inc.All rights reserved.
 */
@Repository("cpsBatchTaskTargetRelQueryDAO")
public class CpsBatchTaskTargetRelQueryDAOImpl extends BaseReadDAOImpl<CpsBatchTaskTargetRel, Long> implements
        CpsBatchTaskTargetRelQueryDAO {

    @Override
    public CpsBatchTaskTargetRel getTargetRelByTargetId(String targetId) {
        String hql = " from CpsBatchTaskTargetRel where batchTargetId =:targetId";
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("targetId", targetId);

        List<CpsBatchTaskTargetRel> list = this.findByHql(hql, param);
        if (list == null || list.size() == 0) {
            return null;
        }
        return list.get(0);
    }

    @Override
    public List<CpsBatchTaskTargetRel> getTargetRelListByTargetId(Long batchtaskId){
        String hql = " from CpsBatchTaskTargetRel where batchTaskId =:batchtaskId";
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("batchtaskId", batchtaskId);

        List<CpsBatchTaskTargetRel> list = this.findByHql(hql, param);
        if (list == null || list.size() == 0) {
            return null;
        }
        return list;
    }

}
